package com.hlw.hr_man.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.hlw.hr_man.Model.EmployeeModel;
import com.hlw.hr_man.service.EmployeeSrevice;
import com.hlw.hr_man.serviceImpl.EmployeeServiceImpl;

import net.sf.json.JSONObject;

public class FindmyinfoController extends HttpServlet {
	EmployeeSrevice employeeservice=new EmployeeServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		HttpSession session=req.getSession();
    	resp.setCharacterEncoding("utf8");
    	PrintWriter pw=resp.getWriter();
    	if(session.getAttribute("loginEmployee")!=null){
      EmployeeModel employeetest=(EmployeeModel) session.getAttribute("loginEmployee");
      String enumber=employeetest.getE_number();
      String epwd=employeetest.getE_password();
      EmployeeModel employee=employeeservice.findEmpByEnumAndEpwd(enumber, epwd);
      JSONObject emjson=JSONObject.fromObject(employee);
      pw.write(emjson.toString());
    	}
	}

}
